home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #11 (Aug 86) / pascal / TML source / keytrans.asm < prev    next >
Assembly Source File  |  1986-07-13  |  2KB  |  70 lines

  1. ; EXAMPLE ASSEMBLY SUBROUTINE
  2. ; key test thing
  3. ; VERSION 11 July 1986
  4. ; (C) Copyright 1986 MacTutor 
  5.  
  6. INCLUDE MACTRAPS.D
  7.    
  8. ;      DECLARE LABELS EXTERNAL
  9.  
  10. XDEF    keyTrans           ; required for linker 
  11.     
  12. ; =========== system globals =============
  13.  
  14. Key1Trans     equ $29E;    { Low Memory Globals }
  15. Key2Trans     equ $2A2;
  16.  
  17. ; =========== key translation routine ======
  18.  
  19. KeyTrans:
  20.  
  21. ; key code (2 bytes) and modifiers (2 bytes) passed 
  22. ; ascii char code returned (2 bytes)
  23.  
  24. link    a6, #-4
  25. movem.l    A0-A1/D0-D2, -(SP)
  26.  
  27. ; get key code from stack into D2
  28. ; get modifiers from stack into D1
  29.  
  30. move.w    8(A6), D1    ;second parameter (modifiers)
  31. move.w    10(A6), D2    ;first parameter (key code)
  32.  
  33. move.w    #9, D0        ;shift count for flags
  34. lsr    D0,D1        ;move bits to lower byte
  35. andi    #7, D1        ;mask 3 bits to get modify in D1
  36.  
  37. cmpi    #64, D2        ;keycode <64 then key1
  38. BGE    key2        ;=>64 then key2
  39.  
  40. key1:
  41. clr.l    D0
  42. LEA    showit, A0    ;get return address
  43. move.l    A0, -(SP)    ;return address to stack
  44. move.l    #key1trans, A0    ;global for pointer to key1trans rom routine
  45. move.l    (A0), A0    ;get address of key1trans
  46. jmp    (A0)        ;call subroutine
  47.  
  48. key2:
  49. subi    #64, D2        ;adjust key code
  50. clr.l    D0
  51. LEA    showit, A0    ;get return address
  52. move.l    A0, -(SP)    ;return address to stack
  53. move.l    #key2trans, A0    ;global for pointer to key2trans rom routine
  54. move.l    (A0), A0    ;get address of key1trans
  55. jmp    (A0)        ;call subroutine
  56.  
  57. showit:
  58.  
  59. ; return function result from D0
  60. move.w    D0, 12(A6)    ;pass back function result
  61.  
  62. movem.l    (SP)+, A0-A1/D0-D2
  63. unlk    a6
  64. move.l    (SP)+, A0    ;get return address
  65. addq.l    #4, SP        ;remove passed parameters
  66. JMP (A0)
  67.  
  68. ; ------------   END OF PROGRAM ----------------
  69.  
  70.